#include "Flashbox4MainView.h"
#include "Flashbox4.hrh"
#include  <aknviewappui.h>


CFlashbox4MainView::~CFlashbox4MainView( )
{
	if(m_pMainContainer)
	{
		AppUi()->RemoveFromViewStack(*this, m_pMainContainer);
		delete m_pMainContainer;
	}
	
}

//
void CFlashbox4MainView::ConstructL()
{
	//继承父类构造
	BaseConstructL();
}

/**
 * From CAknView returns Uid of View
 * @return TUid uid of the view
 */
TUid CFlashbox4MainView::Id( ) const
{
	return TUid::Uid(EMainViewId);
}

/**
 * From MEikMenuObserver delegate commands from the menu
 * @param aCommand a command emitted by the menu 
 * @return void
 */
void CFlashbox4MainView::HandleCommandL(TInt aCommand )
{
	switch(aCommand)
	{
		
	}
}

/**
 * From CAknView reaction if size change
 * @return void
 */
void CFlashbox4MainView::HandleClientRectChange()
{
	if(m_pMainContainer)
	{
		m_pMainContainer->SetExtentToWholeScreen();
	}
}

/**
 * From CAknView activate the view
 * @param aPrevViewId 
 * @param aCustomMessageId 
 * @param aCustomMessage 
 * @return void
 */
void CFlashbox4MainView::DoActivateL(const TVwsViewId& /*aPrevViewId*/, 
		TUid aCustomMessageId, const TDesC8& /*aCustomMessage*/ )
{
	if (!m_pMainContainer )
	{
		m_pMainContainer = new (ELeave) CFlashbox4MainContainer;
		m_pMainContainer->SetMopParent (this);
		m_pMainContainer->ConstructL (ClientRect(), aCustomMessageId.iUid);
		m_pMainContainer->SetExtentToWholeScreen();
		AppUi()->AddToStackL (*this, m_pMainContainer);
	} 
}

/**
 * From CAknView deactivate the view (free resources)
 * @return void
 */
void CFlashbox4MainView::DoDeactivate( )
{
	if ( m_pMainContainer )
	{
		AppUi()->RemoveFromViewStack ( *this, m_pMainContainer );
		delete m_pMainContainer;
		m_pMainContainer = NULL;
	}
}
